package com.hxh.utils
{
	import flash.display.Sprite;
	import flash.filters.*;

	public class Common {

		// Constants:
		// Public Properties:
		// Private Properties:

		// Initialization:
		public function Common() {
		}

		// Public Methods:
		//Format the number with comma eg: 1,000
		public static function addComma(yourNum:Number):String {
			var numtoString:String = new String();
			var numLength:Number=yourNum.toString().length;
			numtoString="";

			for (var iCount:uint=0; iCount<numLength; iCount++) {
				if ((numLength-iCount)%3 == 0 && iCount != 0) {
					numtoString+=",";
				}
				numtoString+=yourNum.toString().charAt(iCount);
			}
			return numtoString;
		}

		public static function addFilter(sprite:Sprite, effect:BitmapFilter):void{
			var fx:Array = sprite.filters;
			fx.push(effect);
			sprite.filters = fx;
		}
		
		public static function removeFilter(sprite:Sprite):void{
			var fx:Array = sprite.filters;
			fx.pop();
			sprite.filters = fx;
		}
		
		
		public static function RGBToHex(r:Number, g:Number, b:Number ):uint {
			var hex:uint=r<<16^g<<8^b;
			return hex;
		}
		
		public static function strToBool(str:Object):Boolean{
			return String(str).toLowerCase() == "true";
		}
	}
}